<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增App基础信息页</title>
    <%@ include file="/basePath.jsp" %>
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/>
    <link rel="stylesheet" href="statics/bootstrap/css/bootstrap.css">
</head>
<body>
<script src="statics/js/jquery-3.6.0.js"></script>
<script src="statics/bootstrap/js/bootstrap.js"></script>
<script>
    $(function () {
        $("#delete").click(function () {
            $("#apk").remove();
            var apkLocPath = $("<input>").attr("type","file").addClass("form-control col-5").attr("name","apkLocPath").attr("id","apkLocPath");
            apkLocPath.appendTo($("#apkContent"));
            //$("#apkLocPath").attr("hidden",false);
            return false;
        })
    })
</script>
<div class="container-fluid" style="min-width: 1000px;">
    <div id="header" class="p-3 border">
        <h1 style="font-size: 18px;">修改App版本信息<small class="ml-3 text-danger">用户：${devName}</small>
        </h1>
    </div>

    <div id="resultList" class="border table-responsive p-3">
        <h2 class="p-2">历史版本列表</h2>
        <table class="table table-striped" style="font-size: 14px;">
            <thead>
            <tr>
                <th scope="col">软件名称</th>
                <th scope="col">版本号</th>
                <th scope="col">版本大小(单位：M)</th>
                <th scope="col">发布状态</th>
                <th scope="col">APK文件下载</th>
                <th scope="col">最近更新时间</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${versions}" var="item" >
                <tr>
                    <td>${softwareName}</td>
                    <td>${item.versionNo}</td>
                    <td>${item.versionSize}</td>
                    <td>${item.publishStatus.publishstatus}</td>
                    <td>${item.apkLocPath}</td>
                    <td>${item.modifyDate}</td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <div class="p-3 border">
        <form class="w-75 m-auto" action="version/${devId}/${id}/${versionId}" method="post" enctype="multipart/form-data">
                <div class="form-group form-row">
                    <label for="versionNo" class="col-3">版本号:</label>
                    <input type="text" class="form-control col-5" id="versionNo" name="versionNo" value="${versionById.versionNo}">
                    <span class="col-4">error</span>
                </div>
                <div class="form-group form-row">
                    <label for="versionSize" class="col-3">版本大小:</label>
                    <input type="text" class="form-control col-5" id="versionSize" name="versionSize" value="${versionById.versionSize}">
                    <span class="col-4">error</span>
                </div>
                <div class="form-group  form-row">
                    <label for="publishstatus" class="col-3">发布状态:</label>
                    <input type="text" class="form-control col-5" name="publishstatus" id="publishstatus" readonly value="预发布">
                    <span class="col-4">error</span>
                </div>
                <div class="form-group  form-row">
                    <label for="versionInfo" class="col-3">版本简介:</label>
                    <textarea class="form-control col-5" cols="50" rows="4" name="versionInfo" id="versionInfo">${versionById.versionInfo}</textarea>
                    <span class="col-4">error</span>
                </div>
                <div class="form-group  form-row" id="apkContent">
                    <label for="apkLocPath" class="col-3">apk文件:</label>
                    <c:if test="${apkLocPath != null}">
                        <div class="form-row col-9" id="apk">
                            <input class="form-control col-6" type="text" readonly name="AlreadApkLocPath" value="${apkLocPath}">
                            <a href="${downloadApkLocPath}" class="text-primary col-2">下载</a>
                            <a href="#" id="delete" class="text-danger col-2">删除</a>
                            <input class="form-control col-1" hidden type="file" name="apkLocPath" id="apkLocPath2"></input>
                        </div>
                    </c:if>
                    <c:if test="${apkLocPath == null}">
                        <input class="form-control col-7"  type="file" name="apkLocPath" id="apkLocPath"></input>
                    </c:if>
                </div>
                <input hidden type="text" name="apkName" value="${apkName}">
                <button type="submit" class="btn btn-primary" id="save">保存</button>
                <a class="btn btn-primary" href="list/${devId}/1">返回</a>
        </form>
    </div>
</div>
</body>
</html>
